//Nathan Popham
//4003-573-01: Procedural Shading
//Lab 3: Task 2 
//
//toon
// this shader implements simple toon/cel shading.
// 
// texturename -- ideally should be gradient, but mess around! Earth is fun.

surface
toon ( string texturename = "";)
{
    color Ct = 1.0;
    
    normal Nn = normalize(N);
    
    if(texturename != "")
    {

        illuminance(P, Nn, PI/2)
        {
            float NdotL = min( max(Nn . normalize(L), 0.0), 0.999);

            //Could pass in either 0.0 or t for the second coordinate
            //it makes no difference if a 1D gradient is passed in
            //but t makes 2D textures look much more interesting 
            Ct *= color texture(texturename, NdotL, t);
        }
    }

    Oi = Os;
    Ci = Ct * Oi;

}
